
const fs = require('fs');
const path = require('path');
const mineType = require('mime-types');
 
var base64img = function(file){
    var filePath = path.resolve(file);
    console.log(filePath);
    var data = fs.readFileSync( path.resolve(filePath));
    data = new Buffer(data).toString('base64');
    return 'data:' + mineType.lookup(filePath) + ';base64,' + data;
}

// console.log(base64img('./static/001.pdf'));
//随便定义一个列表的字段：名字，节目，pdf，时间
const pdf = fs.readFileSync('./static/001.pdf')

const list = [
    {
        name:'JY',
        show:'pandakill',
        pdf:base64img('./static/003.pdf'),
        txt:pdf,
        time:'2016'
    },
    {
        name:'少帮主',
        show:'pandakill',
        pdf:base64img('./static/003.pdf'),
        txt:pdf,
        time:'2018'
    },
    {
        name:'2009',
        show:'dota',
        pdf:base64img('./static/001.pdf'),
        txt:pdf,
        time:'2012'
    },
    {
        name:'囚徒',
        show:'炉石传说',
        pdf:base64img('./static/001.pdf'),
        txt:pdf,
        time:'2017'
    }
]


const listPdf = (req,res) => {
    // console.log('氢气',req);
        res.send({
            status:0,
            msg:'列表拿到手了',
            data:list
        })
}

module.exports = {
    listPdf
}